<#-- 主模板页，包含顶部导航栏和页脚 -->
<#macro masterTemplate navIndex=0>
<#assign navItems = [
    { 'index': 0, 'title': '首页', 'url': '/index'},
    { 'index': 1, 'title': '栏目', 'url': '/category/index'},
    { 'index': 2, 'title': '公告', 'url': '/notice/index'},
    { 'index': 3, 'title': '介绍', 'url': '/presentation/index'},
    { 'index': 4, 'title': '横幅', 'url': '/banner/index', 'enabled': false},
    { 'index': 9, 'title': '文件', 'url': '/file-browser/index'},
    { 'index': 99, 'title': '帮助', 'url': '/help/index'} ]>
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <#-- 找到并输出页面标题 -->
<#list navItems as navItem>
<#if navItem.index == navIndex>
<#if navItem.index == 0>
        <title>Sipahi 内容管理系统</title>
<#else>
        <title>${navItem.title} [Sipahi]</title>
</#if>
<#break>
</#if>
</#list>
        <link rel="shortcut icon" href="<@spring.url '/images/favicon.ico' />" type="image/x-icon">
        <link rel="icon" href="<@spring.url '/images/favicon.ico' />" type="image/x-icon">
        <#include "/css.ftl" />
        <#include "/js.ftl" />
    </head>
    <body>
    <!-- navigation bar -->
    <nav class="navbar sticky-top navbar-expand-lg navbar-dark bg-dark">
        <a class="navbar-brand" href="<@spring.url navItems[0].url />">Sipahi</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav mr-auto">
<#list navItems as navItem>
<#if navItem.index != 0>
<#-- 跳过首页 -->
<#if (navItem.enabled!true)>
<#if navItem.index == navIndex>
        <#-- 输出当前项 -->
                <li class="nav-item active"><a class="nav-link" href="<@spring.url navItem.url />">${navItem.title}<span class="sr-only">(current)</span></a></li>
<#else>
        <#-- 输出非当前项 -->
                <li class="nav-item" ><a class="nav-link" href="<@spring.url navItem.url />">${navItem.title}</a></li>
</#if>
<#else>
                <li class="nav-item" ><a class="nav-link disabled">${navItem.title}</a></li>
</#if>
</#if>
</#list>
            </ul>
            <div class="navbar-text small" >
<#if !(Request.token??)>
                <a class="navbar-link" href="<@spring.url '/sign-in' />">登录</a>&nbsp;
<#else>
                <strong>登录为：${Request.token.name}</strong>&nbsp;|&nbsp;
                <a class="navbar-link" href="<@spring.url '/sign-out' />">退出</a>&nbsp;
</#if>
            </div>
        </div>
    </nav>
    <!-- content -->
    <div class="container">
        <#-- 此处开始输出页面的实际内容 -->
        <#nested />
    </div>
    <!-- footer bar -->
    <footer class="as-footer">
        <div class="container">
            <p>生成页面：${.now?string["yyyy年M月d日H时m分s秒"]}&nbsp;&nbsp;&nbsp;&nbsp;<a>Sipahi 1.0</a></p>
            <p>Powered by <a>Haart</a> 2017, 2018, 2019, 2020</p>
        </div>
    </footer>
    <div id="nonJsonRsp" class="card card-warning as-popup-box" style="visibility: hidden">
        <div class="card-header" >响应结果<button type="button" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>
        <iframe src="about:blank" frameborder="0" class="card-body">
        </iframe>
    </div>
    <div id="overlay" class="as-overlay" ></div>
<script>
'use strict';
$(document).ready(() => {
    $('[data-tooltip]').tooltip({
        title: function() {
            return this.getAttribute('data-tooltip');
        },
        placement: function(et, es) {
            return es.getAttribute('data-tooltip-placement') || 'top';
        },
        html: true,
        container: 'body',
        viewport: 'body'
    });
});
</script>
    </body>
</html>
</#macro>
